﻿using System.Linq;
using System.Xml.Linq;

namespace Coevery.PhoneApp.Convert
{
    public class MetadataHelper
    {
        private static readonly XDocument Metadata;

        static MetadataHelper()
        {
            Metadata = XDocument.Load("Metadata.xml");
        }

        public static string GetLocalizedLabel(string optionSetName,string attribute,string value)
        {
            var data = (Metadata.Descendants("OptionSet").Where(
                query => query.Attribute("name").Value == optionSetName && value == query.Attribute("value").Value).
                Select(query => query.Attribute(attribute).Value)).FirstOrDefault();

            return data ?? string.Empty;
        }
    }
}
